<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .msg-list {
            width: 80%;
            max-width: 600px;
            margin: 16px auto;
            font-size: 18px;
            background-color: #ebebeb;
        }

        .msg-item {
            display: flex;
            padding: 6px;
            margin-inline-end: 48px;
            margin-inline-start: 0px;
        }

        .msg-avatar {
            width: 48px;
            height: 48px;
            object-fit: cover;
            flex-shrink: 0;
        }

        .msg-info {
            padding: 0 6px;
            overflow: hidden;
        }

        .msg-user {
            font-size: 16px;
            color: #949ead;
        }

        .msg-text {
            padding: 6px;
            background-color: #b3d8ff;
            border-radius: 0 12px 12px 12px;
            background: #fff;
            text-align: start;
            /* 防止长英文单词不换行溢出，overflow-wrap就是原word-wrap */
            overflow-wrap: break-word;
        }

        .msg-item[msg-self] {
            flex-direction: row-reverse;
            margin-inline-end: 0px;
            margin-inline-start: 48px;
            text-align: end;
        }

        .msg-item[msg-self] .msg-text {
            border-radius: 12px 0px 12px 12px;
            background: #9CE553;
        }

    </style>
</head>

<body>
    <div class="msg-list">
        <section class="msg-item">
            <img class="msg-avatar" src="html5/icon.png" />
            <div class="msg-info">
                <span class="msg-user">张三</span>
                <p class="msg-text">前端有很多小而美的库，接入成本很低又能满足日常开发需求，同时无论是 npm 方式引入还是直接复制到本地使用都可以。</p>
            </div>
        </section>
        <section class="msg-item" msg-self>
            <img class="msg-avatar" src="html5/icon.png" />
            <div class="msg-info">
                <span class="msg-user">李四</span>
                <p class="msg-text">前端有很多小而美的库。qqqqqqqqqqqqqqq,this is bueqeqie,qeeeeeeeqeqeqeeqeqqeqeqe</p>
            </div>
        </section>
        <section class="msg-item">
            <img class="msg-avatar" src="html5/icon.png" />
            <div class="msg-info">
                <span class="msg-user">王五</span>
                <p class="msg-text">前端有很多小而美的库。</p>
            </div>
        </section>
        <section class="msg-item" msg-self>
            <img class="msg-avatar" src="html5/icon.png" />
            <div class="msg-info">
                <span class="msg-user">李四</span>
                <p class="msg-text">前端有很多小而美的库。</p>
            </div>
        </section>
    </div>
</body>

</html>